const {http ,handleStr,handleStar} = require("../../utils/index")
Page({

    /**
     * 页面的初始数据
     */
    data: {
        book:[]
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(){
        var url= 'http://47.108.197.28:8000/book';
        http({
            url,
            success:result=>{
              this.handleHttpData(result)
            }
        })
      },
    handleHttpData(result){
        var book =[]
        result.data.forEach(item=>{
            var {coverImage,title,rating,evaluate,price,labels} = item;
            var label = labels.join("/")
            book.push({
                coverImage,
                title,
                star:handleStar(rating),
                rating,
                evaluate,
                price,
                label
            })
        })
        this.setData({
            book
        })
},
})